var uriUtil = require('../../utils/uri.js');

Page({

  data: {
    userInfo:{},
    usercalorie:null,
  },

  //页面监听
  onShow: function () {
    let that = this;
    let userInfo = uriUtil.getUserInfo();
    that.setData({
      userInfo: userInfo
    });
    if(userInfo){
      this.qurryCalorie();
    }
  },
  
  //卡路里查询
  qurryCalorie:function(){
    let that = this
    wx.request({
      url: uriUtil.BASE_URL+uriUtil.userCalorieQurry,
      method:"get",
      data:{
        uid:uriUtil.getUserInfo().id,
        day:uriUtil.getDate(),
      },
      success:function(res){
          that.setData({
            usercalorie:res.data,
          })
      },
    })
  },
  //登录
  login:function(){
    wx.navigateTo({
      url: '/pages/login/login',
    })
  },
  //注册
  regist:function(){
    wx.navigateTo({
      url: '/pages/regist/regist',
    })
  },
  //退出登录
  logout: function(){
    uriUtil.removeUserInfo();
    uriUtil.removeDate();
    uriUtil.removeNum();
    this.setData({
      userInfo:{}
    })
    wx.switchTab({
      url: '/pages/index/index',
    })
  },
  //跳转今日记录
  todayRecord: function (e) {
    wx.navigateTo({
      url: '/pages/record/record',
    })
  },
  //反馈
  inform:function(){

  }
})